package com.woniu.cms.goods.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.cms.goods.core.entity.GoodsGetbillMaterial;
import com.woniu.cms.goods.core.mapper.GoodsGetbillMaterialMapper;
import com.woniu.cms.goods.core.service.IGoodsGetbillMaterialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.cms.goods.core.vo.GetbillVo;
import com.woniu.common.api.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 入库单附属材料表，入库单页面材料详情页所显示的材料清单 服务实现类
 * </p>
 *
 * @author romantic sheep
 * @since 2022-09-16
 */
@Service
public class GoodsGetbillMaterialServiceImpl extends ServiceImpl<GoodsGetbillMaterialMapper, GoodsGetbillMaterial> implements IGoodsGetbillMaterialService {

    @Autowired
    private GoodsGetbillMaterialMapper materialMapper;

    @Override
    public Result getlist(Integer currentPage, Integer pageSize, Integer status,String projectCode) {
        List<GetbillVo> getbillVo = materialMapper.getlist(status,projectCode);
        PageInfo<GetbillVo> pageInfo = PageHelper.startPage(currentPage, pageSize).
                doSelectPageInfo(() -> materialMapper.getlist(status,projectCode));
        List<GetbillVo> list = pageInfo.getList();
        long total = pageInfo.getTotal();
        Map map=new HashMap();
        map.put("data",list);
        map.put("total",total);
        Result<Map> common = Result.common(map);
        return common;
    }
}
